<?php  
  	
	include("conn.php");	
 	    
	 
	$t1 = microtime(true); 

	$token=$_REQUEST ["token"]; /// _GET  _POST
	 
	$type=$_REQUEST ["type"];

	$d=$_REQUEST ["d"];

	// http://192.168.1.100/s/search.php?type=1&d=22
	// http://192.168.1.100/s/search.php?type=2&d=s

	if(  $type==NULL || $d==NULL ){
		$jb->code=-1; 
		$jb->test= "no param"; 
		die( json_encode($jb) );  
	}
	 
	 //搜索。  type=1 id搜索  type=2 nickname搜索 
	if($type==1)
	{ 
		$strsql="select uid,nickName,face,maxim from  tb_user where  uid=$d";
	}
	else if($type==2)
	{
		$strsql="select uid,nickName,face,maxim from  tb_user where  nickName like '%$d%'";
	}

		// 执行sql查询
		$result=mysql_query($strsql, $conn);
		  
		// echo $strsql;
		if($result)
		{
			//  •MYSQL_BOTH - 默认  •MYSQL_ASSOC - 关联数组 •MYSQL_NUM - 数字数组
			while ($row = mysql_fetch_array($result ,MYSQL_ASSOC )) 
			{	
				//printf("ID: %s  Name: %s <br>", $row[0], $row[3]);
				$msg[] =$row;

			}

			if($result) mysql_free_result($result);
	  
		}
  

	 
			$t2 = microtime(true); 
		 
			$jb->code=1; 
			$jb->test=  "耗时".round($t2-$t1,6)."秒";  
			$jb->users=$msg;
			echo json_encode($jb);


 mysql_close();

?>  
